<template>
  <div class="app-container">
    <div class="search-bar">
      <el-form ref="queryFormRef" :model="queryParams" :inline="true">
        <el-form-item label="创建时间" prop="createTime">
          <el-date-picker
              v-model="queryParams.createTime"
              type="daterange"
              class="!w-[250px]"
              range-separator="-"
              start-placeholder="开始时间"
              end-placeholder="结束时间"
              value-format="YYYY-MM-DD HH:mm:ss"
          />
        </el-form-item>
        <el-form-item label="部门" prop="deptId">
          <el-tree-select
              v-model="queryParams.deptId"
              placeholder="全部"
              :data="deptOptions"
              filterable
              clearable
              check-strictly
              :render-after-expand="false"
              style="width: 250px"
          />
        </el-form-item>
        <el-form-item label="用户名称" prop="userName">
          <el-input
              v-model="queryParams.userName"
              placeholder="用户名称"
              clearable
              @keyup.enter="handleQuery()"
              style="width: 250px"
          />
        </el-form-item>
        <el-form-item label="文件标识" prop="fileName">
          <el-input
              v-model="queryParams.fileName"
              placeholder="文件标识"
              clearable
              @keyup.enter="handleQuery()"
              style="width: 250px"
          />
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="handleQuery">
            <template #icon>
              <Search/>
            </template>
            搜索
          </el-button>
          <el-button @click="handleResetQuery">
            <template #icon>
              <Refresh/>
            </template>
            重置
          </el-button>
        </el-form-item>
      </el-form>
    </div>

    <el-card shadow="never">
      <div class="mb-10px">
        <el-button
            v-hasPerm="'system:lpsOrder:import'"
            type="success"
            @click="handleOpenImportDialog"
        >
          <template #icon>
            <Upload/>
          </template>
          导入
        </el-button>
        <!--        <el-button-->
        <!--            v-hasPerm="['system:lpsOrder:download']"-->
        <!--            type="success"-->
        <!--            :disabled="downloadIds.length === 0"-->
        <!--            @click="handleDownload()"-->
        <!--        >-->
        <!--          <template #icon>-->
        <!--            <Download/>-->
        <!--          </template>-->
        <!--          下载-->
        <!--        </el-button>-->
        <el-button
            v-hasPerm="['system:lpsOrder:delete']"
            type="danger"
            :disabled="removeIds.length === 0"
            @click="handleDelete()"
        >
          <template #icon>
            <Delete/>
          </template>
          删除
        </el-button>
      </div>

      <el-table
          ref="dataTableRef"
          v-loading="loading"
          :data="pageData"
          highlight-current-row
          border
          @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="50" align="center"/>
        <el-table-column type="index" label="序号" width="80" align="center"/>
        <el-table-column
            key="deptName"
            label="部门名称"
            prop="deptName"
            min-width="250"
            align="center"
            :show-overflow-tooltip="true"
        />
        <el-table-column
            key="fileName"
            label="文件标识"
            prop="fileName"
            min-width="350"
            align="center"
            :show-overflow-tooltip="true"
        />
        <el-table-column
            key="createTime"
            label="创建时间"
            prop="createTime"
            width="200"
            align="center"
        />
        <el-table-column
            key="userName"
            label="创建用户"
            prop="userName"
            width="200"
            align="center"
            :show-overflow-tooltip="true"
        />
        <el-table-column
            key="updateTime"
            label="更新时间"
            prop="updateTime"
            width="200"
            align="center"
        />
        <el-table-column
            key="updateUserName"
            label="更新用户"
            prop="updateUserName"
            width="200"
            align="center"
            :show-overflow-tooltip="true"
        />

        <!--        <el-table-column-->
        <!--            key="filePath"-->
        <!--            label="文件路径"-->
        <!--            prop="filePath"-->
        <!--            min-width="200"-->
        <!--            align="center"-->
        <!--            :show-overflow-tooltip="true"-->
        <!--        />-->
        <!--        <el-table-column-->
        <!--            key="remark"-->
        <!--            label="备注"-->
        <!--            prop="remark"-->
        <!--            min-width="300"-->
        <!--            align="center"-->
        <!--            :show-overflow-tooltip="true"-->
        <!--        />-->
        <el-table-column fixed="right" label="操作" width="220" align="center">
          <template #default="scope">
            <el-button
                v-hasPerm="['system:lpsOrder:download']"
                type="primary"
                size="small"
                link
                @click="handleDownload(scope.row.id)"
            >
              <template #icon>
                <Download/>
              </template>
              下载
            </el-button>
            <el-button
                v-hasPerm="['system:lpsOrder:edit']"
                type="primary"
                size="small"
                link
                @click="handleOpenDialog(scope.row.id)"
            >
              <template #icon>
                <Edit/>
              </template>
              查看
            </el-button>
            <el-button
                v-hasPerm="['system:lpsOrder:delete']"
                type="danger"
                size="small"
                link
                @click="handleDelete(scope.row.id)"
            >
              <template #icon>
                <Delete/>
              </template>
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
          v-if="total > 0"
          v-model:total="total"
          v-model:page="queryParams.pageNum"
          v-model:limit="queryParams.pageSize"
          @pagination="handleQuery()"
      />
    </el-card>

    <!-- 莱普森订单表单弹窗 -->
    <el-dialog
        v-model="dialog.visible"
        :title="dialog.title"
        width="85%"
        @close="handleCloseDialog"
    >
      <el-form ref="dataFormRef" :model="formData" :rules="rules" label-width="100px">
        <!--        <el-form-item label="文件名称" prop="fileName">-->
        <!--          <el-input v-model="formData.fileName" clearable maxlength="64" show-word-limit placeholder="文件名称"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="备注" prop="remark">-->
        <!--          <el-input v-model="formData.remark" type="textarea" rows="4" maxlength="1024" show-word-limit clearable-->
        <!--                    placeholder="备注"/>-->
        <!--        </el-form-item>-->
        <el-tabs v-model="activeTab" class="left-centered-tabs">
          <el-tab-pane label="触动机构" name="触动机构"></el-tab-pane>
          <el-tab-pane label="触动机构+C" name="触动机构+C"></el-tab-pane>
          <el-tab-pane label="新产品 线" name="新产品 线"></el-tab-pane>
          <el-tab-pane label="新产品" name="新产品"></el-tab-pane>
          <el-tab-pane label="配件" name="配件"></el-tab-pane>
          <el-tab-pane label="扶手" name="扶手"></el-tab-pane>
          <el-tab-pane label="永乐" name="永乐"></el-tab-pane>
          <el-tab-pane label="利居" name="利居"></el-tab-pane>
        </el-tabs>

        <div v-show="activeTab === '触动机构'">
          <el-table :data="formData.cdjgList" border style="width: 100%; margin-top: 20px" height="600px">
            <el-table-column type="index" label="序号" width="70" align="center" fixed="left"/>
            <el-table-column
                key="cgdd"
                label="采购订单"
                prop="cgdd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="poxxm"
                label="PO行项目"
                prop="poxxm"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="xsdd"
                label="销售订单"
                prop="xsdd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="soxxm"
                label="SO行项目"
                prop="soxxm"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="wl"
                label="物料"
                prop="wl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="ms"
                label="描述"
                prop="ms"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="thbb"
                label="图号/版本"
                prop="thbb"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="sl"
                label="数量"
                prop="sl"
                min-width="80"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="jhrq"
                label="交货日期"
                prop="jhrq"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="kcd"
                label="库存地"
                prop="kcd"
                min-width="120"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="cw1"
                label="仓位1"
                prop="cw1"
                min-width="120"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="bks"
                label="BKS"
                prop="bks"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="cdjgzd"
                label="触动机构长度"
                prop="cdjgzd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpHqbCar"
                label="GRP_HQB_CAR"
                prop="grpHqbCar"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="sldhys"
                label="数量/弹簧颜色"
                prop="sldhys"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="bz"
                label="备注"
                prop="bz"
                width="300"
                align="center"
                :show-overflow-tooltip="true"
            />
          </el-table>
        </div>
        <div v-show="activeTab === '触动机构+C'">
          <el-table :data="formData.cdjgCList" border style="width: 100%; margin-top: 20px" height="600px">
            <el-table-column type="index" label="序号" width="70" align="center" fixed="left"/>
            <el-table-column
                key="cgdd"
                label="采购订单"
                prop="cgdd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="poxxm"
                label="PO行项目"
                prop="poxxm"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="xsdd"
                label="销售订单"
                prop="xsdd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="soxxm"
                label="SO行项目"
                prop="soxxm"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="wl"
                label="物料"
                prop="wl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="ms"
                label="描述"
                prop="ms"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="thbb"
                label="图号/版本"
                prop="thbb"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="sl"
                label="数量"
                prop="sl"
                min-width="80"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="jhrq"
                label="交货日期"
                prop="jhrq"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="kcd"
                label="库存地"
                prop="kcd"
                min-width="120"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="cw1"
                label="仓位1"
                prop="cw1"
                min-width="120"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="bks"
                label="BKS"
                prop="bks"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="cdjgzd"
                label="触动机构长度"
                prop="cdjgzd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpHqbCar"
                label="GRP_HQB_CAR"
                prop="grpHqbCar"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="sldhys"
                label="数量/弹簧颜色"
                prop="sldhys"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="bz"
                label="备注"
                prop="bz"
                width="300"
                align="center"
                :show-overflow-tooltip="true"
            />
          </el-table>
        </div>
        <div v-show="activeTab === '新产品 线'">
          <el-table :data="formData.xianList" border style="width: 100%; margin-top: 20px" height="600px" :span-method="objectSpanMethod">

            <el-table-column type="index" label="序号" width="70" align="center" fixed="left"/>
            <el-table-column
                key="cgdd"
                label="采购订单"
                prop="cgdd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="poxxm"
                label="PO行项目"
                prop="poxxm"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="xsdd"
                label="销售订单"
                prop="xsdd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="soxxm"
                label="SO行项目"
                prop="soxxm"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="wl"
                label="物料"
                prop="wl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="ms"
                label="描述"
                prop="ms"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="thbb"
                label="图号/版本"
                prop="thbb"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="zj"
                label="子件"
                prop="zj"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="sl"
                label="数量"
                prop="sl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="jhrq"
                label="交货日期"
                prop="jhrq"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="kcd"
                label="库存地"
                prop="kcd"
                min-width="120"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="cw1"
                label="仓位1"
                prop="cw1"
                min-width="120"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="azszgjhdq"
                label="安装所在国家或地区"
                prop="azszgjhdq"
                min-width="180"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="carSafetyGearType"
                label="CAR_SAFETY_GEAR_TYPE"
                prop="carSafetyGearType"
                min-width="220"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="hk"
                label="HK"
                prop="hk"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="bk"
                label="BK"
                prop="bk"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="tk"
                label="TK"
                prop="tk"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpAlarmType"
                label="GRP_ALARM_TYPE"
                prop="grpAlarmType"
                min-width="180"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="marketCluster"
                label="MARKET_CLUSTER"
                prop="marketCluster"
                min-width="180"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="sckLmsType"
                label="SCK_LMS_TYPE"
                prop="sckLmsType"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="dxlx"
                label="电线类型"
                prop="dxlx"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="kgsl"
                label="开关数量"
                prop="kgsl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <!--            <el-table-column-->
            <!--                key="dxsl"-->
            <!--                label="电线数量"-->
            <!--                prop="dxsl"-->
            <!--                min-width="150"-->
            <!--                align="center"-->
            <!--                :show-overflow-tooltip="true"-->
            <!--            />-->
            <el-table-column
                key="dxzd"
                label="电线长度"
                prop="dxzd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="dxjsz"
                label="电线计算值"
                prop="dxjsz"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="bz"
                label="备注"
                prop="bz"
                width="300"
                align="center"
                :show-overflow-tooltip="true"
            />
          </el-table>
        </div>
        <div v-show="activeTab === '新产品'">
          <el-table :data="formData.xcpList" border style="width: 100%; margin-top: 20px" height="600px">
            <el-table-column type="index" label="序号" width="70" align="center" fixed="left"/>
            <el-table-column
                key="cgdd"
                label="采购订单"
                prop="cgdd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="poxxm"
                label="PO行项目"
                prop="poxxm"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="xsdd"
                label="销售订单"
                prop="xsdd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="soxxm"
                label="SO行项目"
                prop="soxxm"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="wl"
                label="物料"
                prop="wl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="ms"
                label="描述"
                prop="ms"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="thbb"
                label="图号/版本"
                prop="thbb"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="sl"
                label="数量"
                prop="sl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="jhrq"
                label="交货日期"
                prop="jhrq"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="kcd"
                label="库存地"
                prop="kcd"
                min-width="120"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="cw1"
                label="仓位1"
                prop="cw1"
                min-width="120"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="jgdbz"
                label="激光打标字"
                prop="jgdbz"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="bk"
                label="BK"
                prop="bk"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="tk"
                label="TK"
                prop="tk"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="gq"
                label="GQ"
                prop="gq"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="p00Tsd"
                label="P00_TSD"
                prop="p00Tsd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="code"
                label="CODE"
                prop="code"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="p00RetainerType"
                label="P00_RETAINER_TYPE"
                prop="p00RetainerType"
                width="185"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="p00Intercom"
                label="P00_INTERCOM"
                prop="p00Intercom"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="p00ApronType"
                label="P00_APRON_TYPE"
                prop="p00ApronType"
                width="165"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="p00TbType"
                label="P00_TB_TYPE"
                prop="p00TbType"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="p00StructureType"
                label="P00_STRUCTURE_TYPE"
                prop="p00StructureType"
                width="200"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="drivePos"
                label="DRIVE_POS"
                prop="drivePos"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="bz"
                label="备注"
                prop="bz"
                width="300"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column fixed="right" label="操作" width="100" align="center">
              <template #default="scope">
                <el-button
                    type="primary"
                    size="small"
                    link
                    @click="handleOpenDialogXcp(scope.row)"
                >
                  <template #icon>
                    <Edit/>
                  </template>
                  编辑
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div v-show="activeTab === '配件'">
          <el-table :data="formData.pjList" border style="width: 100%; margin-top: 20px" height="600px">
            <el-table-column type="index" label="序号" width="70" align="center" fixed="left"/>
            <el-table-column
                key="cgdd"
                label="采购订单"
                prop="cgdd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="poxxm"
                label="PO行项目"
                prop="poxxm"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="xsdd"
                label="销售订单"
                prop="xsdd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="soxxm"
                label="SO行项目"
                prop="soxxm"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="wl"
                label="物料"
                prop="wl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="ms"
                label="描述"
                prop="ms"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="thbb"
                label="图号/版本"
                prop="thbb"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="sl"
                label="数量"
                prop="sl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="jhrq"
                label="交货日期"
                prop="jhrq"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="kcd"
                label="库存地"
                prop="kcd"
                min-width="120"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="cw1"
                label="仓位1"
                prop="cw1"
                min-width="120"
                align="center"
                :show-overflow-tooltip="true"
            />
            <!--            <el-table-column-->
            <!--                key="azszgjhdq"-->
            <!--                label="安装所在国家或地区"-->
            <!--                prop="azszgjhdq"-->
            <!--                min-width="180"-->
            <!--                align="center"-->
            <!--                :show-overflow-tooltip="true"-->
            <!--            />-->
            <el-table-column
                key="kzu"
                label="KZU"
                prop="kzu"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="bks"
                label="BKS"
                prop="bks"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="cdjgzd"
                label="触动机构长度"
                prop="cdjgzd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="elevatorSystem"
                label="ELEVATOR_SYSTEM"
                prop="elevatorSystem"
                min-width="180"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="carSlingVariant"
                label="CAR_SLING_VARIANT"
                prop="carSlingVariant"
                width="185"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="carSafetyGearType"
                label="CAR_SAFETY_GEAR_TYPE"
                prop="carSafetyGearType"
                min-width="220"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="qzgzd"
                label="起重管长度"
                prop="qzgzd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="bz"
                label="备注"
                prop="bz"
                width="300"
                align="center"
                :show-overflow-tooltip="true"
            />
          </el-table>
        </div>
        <div v-show="activeTab === '扶手'">
          <el-table :data="formData.fsList" border style="width: 100%; margin-top: 20px" height="600px">
            <el-table-column type="index" label="序号" width="70" align="center" fixed="left"/>
            <el-table-column
                key="cgdd"
                label="采购订单"
                prop="cgdd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="poxxm"
                label="PO行项目"
                prop="poxxm"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="xsdd"
                label="销售订单"
                prop="xsdd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="soxxm"
                label="SO行项目"
                prop="soxxm"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="wl"
                label="物料"
                prop="wl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="ms"
                label="描述"
                prop="ms"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="thbb"
                label="图号/版本"
                prop="thbb"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="sl"
                label="数量"
                prop="sl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="jhrq"
                label="交货日期"
                prop="jhrq"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="kcd"
                label="库存地"
                prop="kcd"
                min-width="120"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="cw1"
                label="仓位1"
                prop="cw1"
                min-width="120"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="bk"
                label="BK"
                prop="bk"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="tk"
                label="TK"
                prop="tk"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="tkwcLeft"
                label="TKWC_LEFT"
                prop="tkwcLeft"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="tkwoLeft"
                label="TKWO_LEFT"
                prop="tkwoLeft"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="tkwcRight"
                label="TKWC_RIGHT"
                prop="tkwcRight"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="tkwoRight"
                label="TKWO_RIGHT"
                prop="tkwoRight"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpWallBaseTypeLeft"
                label="GRP_WALL_BASE_TYPE_LEFT"
                prop="grpWallBaseTypeLeft"
                min-width="250"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpWallBaseTypeRight"
                label="GRP_WALL_BASE_TYPE_RIGHT"
                prop="grpWallBaseTypeRight"
                min-width="255"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpWallBaseTypeRear"
                label="GRP_WALL_BASE_TYPE_REAR"
                prop="grpWallBaseTypeRear"
                min-width="255"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpCopTkt1"
                label="GRP_COP_TKT1 "
                prop="grpCopTkt1"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpCopTkt2"
                label="GRP_COP_TKT2"
                prop="grpCopTkt2"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpCopTkt3"
                label="GRP_COP_TKT3"
                prop="grpCopTkt3"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpCopTkt4"
                label="GRP_COP_TKT4"
                prop="grpCopTkt4"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="kja"
                label="孔距A"
                prop="kja"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="kjb"
                label="孔距B"
                prop="kjb"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="fszd"
                label="扶手长度(L)"
                prop="fszd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="gdzjsl"
                label="固定支架数量"
                prop="gdzjsl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="bmcl"
                label="表面处理"
                prop="bmcl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="dj"
                label="垫圈"
                prop="dj"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="bz"
                label="备注"
                prop="bz"
                width="300"
                align="center"
                :show-overflow-tooltip="true"
            />
          </el-table>
        </div>
        <div v-show="activeTab === '永乐'">
          <el-table :data="formData.ylList" border style="width: 100%; margin-top: 20px" height="600px">
            <el-table-column type="index" label="序号" width="70" align="center" fixed="left"/>
            <el-table-column
                key="cgdd"
                label="采购订单"
                prop="cgdd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="poxxm"
                label="PO行项目"
                prop="poxxm"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="xsdd"
                label="销售订单"
                prop="xsdd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="soxxm"
                label="SO行项目"
                prop="soxxm"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="wl"
                label="物料"
                prop="wl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="ms"
                label="描述"
                prop="ms"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="thbb"
                label="图号/版本"
                prop="thbb"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="sl"
                label="数量"
                prop="sl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="jhrq"
                label="交货日期"
                prop="jhrq"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="bk"
                label="BK"
                prop="bk"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="tk"
                label="TK"
                prop="tk"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="tkwcLeft"
                label="TKWC_LEFT"
                prop="tkwcLeft"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="tkwoLeft"
                label="TKWO_LEFT"
                prop="tkwoLeft"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="tkwcRight"
                label="TKWC_RIGHT"
                prop="tkwcRight"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="tkwoRight"
                label="TKWO_RIGHT"
                prop="tkwoRight"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpWallBaseTypeLeft"
                label="GRP_WALL_BASE_TYPE_LEFT"
                prop="grpWallBaseTypeLeft"
                min-width="250"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpWallBaseTypeRight"
                label="GRP_WALL_BASE_TYPE_RIGHT"
                prop="grpWallBaseTypeRight"
                min-width="255"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpWallBaseTypeRear"
                label="GRP_WALL_BASE_TYPE_REAR"
                prop="grpWallBaseTypeRear"
                min-width="255"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpCopTkt1"
                label="GRP_COP_TKT1 "
                prop="grpCopTkt1"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpCopTkt2"
                label="GRP_COP_TKT2"
                prop="grpCopTkt2"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpCopTkt3"
                label="GRP_COP_TKT3"
                prop="grpCopTkt3"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpCopTkt4"
                label="GRP_COP_TKT4"
                prop="grpCopTkt4"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="kja"
                label="孔距A"
                prop="kja"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="kjb"
                label="孔距B"
                prop="kjb"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="fszd"
                label="扶手长度(L)"
                prop="fszd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="gdzjsl"
                label="固定支架数量"
                prop="gdzjsl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="bmcl"
                label="表面处理"
                prop="bmcl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="dj"
                label="垫圈"
                prop="dj"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="bz"
                label="备注"
                prop="bz"
                width="300"
                align="center"
                :show-overflow-tooltip="true"
            />
          </el-table>
        </div>
        <div v-show="activeTab === '利居'">
          <el-table :data="formData.ljList" border style="width: 100%; margin-top: 20px" height="600px">
            <el-table-column type="index" label="序号" width="70" align="center" fixed="left"/>
            <el-table-column
                key="cgdd"
                label="采购订单"
                prop="cgdd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="poxxm"
                label="PO行项目"
                prop="poxxm"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="xsdd"
                label="销售订单"
                prop="xsdd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="soxxm"
                label="SO行项目"
                prop="soxxm"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="wl"
                label="物料"
                prop="wl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="ms"
                label="描述"
                prop="ms"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="thbb"
                label="图号/版本"
                prop="thbb"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="sl"
                label="数量"
                prop="sl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="jhrq"
                label="交货日期"
                prop="jhrq"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="bk"
                label="BK"
                prop="bk"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="tk"
                label="TK"
                prop="tk"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="tkwcLeft"
                label="TKWC_LEFT"
                prop="tkwcLeft"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="tkwoLeft"
                label="TKWO_LEFT"
                prop="tkwoLeft"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="tkwcRight"
                label="TKWC_RIGHT"
                prop="tkwcRight"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="tkwoRight"
                label="TKWO_RIGHT"
                prop="tkwoRight"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpWallBaseTypeLeft"
                label="GRP_WALL_BASE_TYPE_LEFT"
                prop="grpWallBaseTypeLeft"
                min-width="250"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpWallBaseTypeRight"
                label="GRP_WALL_BASE_TYPE_RIGHT"
                prop="grpWallBaseTypeRight"
                min-width="255"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpWallBaseTypeRear"
                label="GRP_WALL_BASE_TYPE_REAR"
                prop="grpWallBaseTypeRear"
                min-width="255"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpCopTkt1"
                label="GRP_COP_TKT1 "
                prop="grpCopTkt1"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpCopTkt2"
                label="GRP_COP_TKT2"
                prop="grpCopTkt2"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpCopTkt3"
                label="GRP_COP_TKT3"
                prop="grpCopTkt3"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="grpCopTkt4"
                label="GRP_COP_TKT4"
                prop="grpCopTkt4"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="kja"
                label="孔距A"
                prop="kja"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="kjb"
                label="孔距B"
                prop="kjb"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="fszd"
                label="扶手长度(L)"
                prop="fszd"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="gdzjsl"
                label="固定支架数量"
                prop="gdzjsl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="bmcl"
                label="表面处理"
                prop="bmcl"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="dj"
                label="垫圈"
                prop="dj"
                min-width="150"
                align="center"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                key="bz"
                label="备注"
                prop="bz"
                width="300"
                align="center"
                :show-overflow-tooltip="true"
            />
          </el-table>
        </div>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="handleSubmit()">确定</el-button>
          <el-button @click="handleCloseDialog()">取消</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 新产品表单弹窗 -->
    <el-dialog
        v-model="dialogXcp.visible"
        :title="dialogXcp.title"
        width="500px"
        @close="handleCloseDialogXcp"
        :close-on-click-modal="false"
    >
      <el-form ref="dataFormRefXcp" :model="formDataXcp" label-width="100px">
        <el-form-item label="激光打标字" prop="jgdbz">
          <el-input
              v-model="formDataXcp.jgdbz"
              placeholder="激光打标字"
              maxlength="64"
              show-word-limit
              clearable
          />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="handleSubmitXcp()">确定</el-button>
          <el-button @click="handleCloseDialogXcp()">取消</el-button>
        </div>
      </template>
    </el-dialog>

    <!--    <Import v-model="importDialogVisible" @import-success="handleQuery()"/>-->
    <Import v-model="importDialogVisible" @reset-query="handleResetQuery"/>
  </div>
</template>

<script setup lang="ts">
import DeptAPI from "@/api/system/dept";
import LpsOrderAPI, {LpsOrderForm, LpsOrderPageQuery, LpsOrderPageVO,} from "@/api/system/lps-order";
import {LpsOrderXcpForm} from "@/api/system/lps-order-xcp";
import {TableColumnCtx} from "element-plus";
import {LpsOrderPjPageVO} from "@/api/system/lps-order-pj";
import {LpsOrderXianPageVO} from "@/api/system/lps-order-xian";

defineOptions({
  name: "LpsOrder",
  inheritAttrs: false,
});

const dataFormRefXcp = ref(ElForm);
const activeTab = ref("触动机构");

// eslint-disable-next-line no-undef
const queryFormRef = ref(ElForm);
// eslint-disable-next-line no-undef
const dataFormRef = ref(ElForm);

const loading = ref(false);
const removeIds = ref<number[]>([]);
const downloadIds = ref<number[]>([]);
const total = ref(0);
const fileUrls = ref([]);
// 导入弹窗显示状态
const importDialogVisible = ref(false);
const queryParams = reactive<LpsOrderPageQuery>({
  pageNum: 1,
  pageSize: 10,
});
const deptOptions = ref<OptionType[]>();
// 莱普森订单表格数据
const pageData = ref<LpsOrderPageVO[]>([]);

// 弹窗
const dialog = reactive({
  title: "",
  visible: false,
});
// 弹窗
const dialogXcp = reactive({
  title: "",
  visible: false,
});

// 莱普森订单表单数据
const formData = reactive<LpsOrderForm>({});
const formDataXcp = reactive<LpsOrderXcpForm>({});

// 莱普森订单表单校验规则
const rules = reactive({
  fileName: [{required: true, message: "请输入文件名称", trigger: "blur"}],
});

/** 查询莱普森订单 */
function handleQuery() {
  loading.value = true;
  LpsOrderAPI.getPage(queryParams)
      .then((data) => {
        pageData.value = data.list;
        total.value = data.total;
      })
      .finally(() => {
        loading.value = false;
      });
}

/** 重置莱普森订单查询 */
function handleResetQuery() {
  queryFormRef.value!.resetFields();
  queryParams.pageNum = 1;
  handleQuery();
}

/** 行复选框选中记录选中ID集合 */
function handleSelectionChange(selection: any) {
  removeIds.value = selection.map((item: any) => item.id);
  downloadIds.value = selection.map((item: any) => item.id);
}

/** 打开莱普森订单弹窗 */
function handleOpenDialog(id?: number) {
  dialog.visible = true;
  if (id) {
    dialog.title = "莱普森订单";
    LpsOrderAPI.getFormData(id).then((data) => {
      Object.assign(formData, data);
    });
  } else {
    dialog.title = "莱普森订单";
  }
}

/** 提交莱普森订单表单 */
function handleSubmit() {
  dataFormRef.value.validate((valid: any) => {
    if (valid) {
      console.log(fileUrls.value);
      loading.value = true;
      const id = formData.id;
      if (id) {
        LpsOrderAPI.update(id, formData)
            .then(() => {
              ElMessage.success("更新成功");
              handleCloseDialog();
              handleResetQuery();
            })
            .finally(() => (loading.value = false));
      } else {
        LpsOrderAPI.add(formData)
            .then(() => {
              ElMessage.success("新增成功");
              handleCloseDialog();
              handleResetQuery();
            })
            .finally(() => (loading.value = false));
      }
    }
  });
}

/** 关闭莱普森订单弹窗 */
function handleCloseDialog() {
  dialog.visible = false;
  dataFormRef.value.resetFields();
  dataFormRef.value.clearValidate();
  formData.id = undefined;
}

/** 删除莱普森订单 */
function handleDelete(id?: number) {
  const ids = [id || removeIds.value].join(",");
  if (!ids) {
    ElMessage.warning("请勾选删除项");
    return;
  }
  ElMessageBox.confirm("确认删除已选中的数据项?", "警告", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
  }).then(
      () => {
        loading.value = true;
        LpsOrderAPI.deleteByIds(ids)
            .then(() => {
              ElMessage.success("删除成功");
              handleResetQuery();
            })
            .finally(() => (loading.value = false));
      },
      () => {
        ElMessage.info("已取消删除");
      }
  );
}

/** 下载莱普森订单 */
function handleDownload(id?: number) {
  const ids = [id || downloadIds.value].join(",");
  if (!ids) {
    ElMessage.warning("请勾选下载项");
    return;
  }
  queryParams.ids = ids;

  LpsOrderAPI.downloadByIds(queryParams).then((response: any) => {
    const fileData = response.data;

    // 从 Content-Disposition 中提取文件名
    const disposition = response.headers["content-disposition"];
    let fileName = "莱普森订单.zip";
    if (disposition && disposition.indexOf("filename=") !== -1) {
      fileName = decodeURIComponent(
          disposition
              .split("filename=")[1]
              .split(";")[0]
              .replace(/UTF-8''/i, "")
              .trim()
      );
    }

    // 使用正确的 MIME 类型 application/zip
    const blob = new Blob([fileData], {type: "application/zip"});
    const downloadUrl = window.URL.createObjectURL(blob);

    const downloadLink = document.createElement("a");
    downloadLink.href = downloadUrl;
    downloadLink.download = fileName;
    document.body.appendChild(downloadLink);
    downloadLink.click();

    document.body.removeChild(downloadLink);
    window.URL.revokeObjectURL(downloadUrl);

    ElMessage.success("下载成功");
  });
}

/** 打开新产品弹窗 */
function handleOpenDialogXcp(row: any) {
  dialogXcp.visible = true;
  dialogXcp.title = "新产品";
  Object.assign(formDataXcp, row);
}

/** 关闭新产品弹窗 */
function handleCloseDialogXcp() {
  dialogXcp.visible = false;
  dataFormRefXcp.value.resetFields();
  dataFormRefXcp.value.clearValidate();
}

/** 提交新产品弹窗 */
function handleSubmitXcp() {
  const index = formData.xcpList.findIndex(
      (item) => item.id === formDataXcp.id
  );
  if (index > -1) {
    Object.assign(formData.xcpList[index], formDataXcp);
  }
  handleCloseDialogXcp();
}

// 打开导入弹窗
function handleOpenImportDialog() {
  importDialogVisible.value = true;
}


interface SpanMethodProps {
  row: LpsOrderXianPageVO
  column: TableColumnCtx<LpsOrderXianPageVO>
  rowIndex: number
  columnIndex: number
}

const objectSpanMethod = ({
                            row,
                            column,
                            rowIndex,
                            columnIndex,
                          }: SpanMethodProps) => {
  const mergeColumns = [1, 2, 3, 4, 5, 6, 7];

  // 如果不是合并列，直接返回默认值
  if (!mergeColumns.includes(columnIndex)) {
    return {rowspan: 1, colspan: 1};
  }

  // 获取当前列对应的字段名
  const field = column.property as keyof LpsOrderXianPageVO;

  // 如果是第一行，或当前行的 wl 与上一行不同，开始合并
  if (rowIndex === 0 || row.rowId !== formData.xianList[rowIndex - 1].rowId) {
    let count = 1;
    // 向下查找相同物料的行数
    for (let i = rowIndex + 1; i < formData.xianList.length; i++) {
      if (formData.xianList[i].rowId === row.rowId) {
        count++;
      } else {
        break;
      }
    }
    return {rowspan: count, colspan: 1};
  }
  // 其他行不显示
  return {rowspan: 0, colspan: 0};
};

if (onMounted) {
  onMounted(async () => {
    // 加载区域下拉数据源
    deptOptions.value = await DeptAPI.getOptions();
    handleQuery();
  });
}
</script>
<style scoped>
:deep(.el-input-number .el-input__inner) {
  text-align: left !important;
}

:deep(.el-popper) {
  max-width: 500px;
}
</style>
